package SyntheticData;

import java.util.ArrayList;

/**
 *
 */
public class Graph {
    private ArrayList<Vertex> vertices;
    private ArrayList<ArrayList<Vertex>> arcs;

    Graph() {
        this.vertices = new ArrayList<Vertex>(0);
        this.arcs = new ArrayList<ArrayList<Vertex>>(0);
    }

    public void addVertex(Vertex v) {
        vertices.add(v);
    }

    public void addArcs(ArrayList<Vertex> a) {
        arcs.add(a);
    }

    public int numVertices() {
        return vertices.size();
    }

    public Vertex getVertex(int i) {
        return vertices.get(i);
    }

    public Vertex randomVertex() {
        int i = (int) (Math.random() * vertices.size());
        return vertices.get(i);
    }

    public int numArcs() {
        int n = 0;
        for (int i = 0; i < vertices.size(); i++) {
            n += arcs.get(i).size();
        }
        return n;
    }

    public ArrayList<Vertex> getArcs(Vertex v) {
        return arcs.get(v.getIndex());
    }
}
